package com.brightgenerous.niconama05.work4;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.UIManager;

/**
 * HTMLを表示するFrameクラス
 * 
 * @author brigen
 */
class HtmlFrame extends JFrame {

	/** シリアル・バージョンID */
	private static final long serialVersionUID = 2450033293117751755L;

	/**
	 * コンストラクタ
	 *
	 * @param x_html HTML文字列
	 */
	public HtmlFrame(String x_html) {
		super("Niconama05");

		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (Exception e) {
			e.printStackTrace();
		}

		JEditorPane htmlPane = new JEditorPane("text/html", x_html);
		htmlPane.setEditable(false);

		Container container = getContentPane();
		container.setLayout(new BorderLayout());

		JScrollPane scroll = new JScrollPane(htmlPane);
		scroll.setPreferredSize(new Dimension(710, 300));
		scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

		container.add(scroll, BorderLayout.CENTER);

		pack();

		Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
		int x = (d.width - getWidth()) / 2;
		int y = (d.height - getHeight()) / 2;
		setLocation(x, y);

		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
}